package com.zking.Dao;

import java.sql.Connection;
import java.sql.SQLException;

import org.apache.tomcat.dbcp.dbcp.BasicDataSource;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class DBUtil {
	
	public static Connection getConnection() {
		AbstractApplicationContext ac = new ClassPathXmlApplicationContext("application-Dao.xml");
		BasicDataSource bs = ac.getBean("database",BasicDataSource.class);
		
		try {
			return bs.getConnection();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
}
